home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / fcheck1r / module1.bas < prev    next >
BASIC Source File  |  1999-08-18  |  2KB  |  40 lines

  1. Attribute VB_Name = "Module1"
  2.  
  3. Public Sub SaveWindowPos(ByVal frm As Form)
  4.  
  5.  
  6.     ' Save window position and size attributes to registry
  7.     SaveSetting App.Title, "Config", frm.Name + "_left", CStr(frm.Left)
  8.     SaveSetting App.Title, "Config", frm.Name + "_top", CStr(frm.Top)
  9.     SaveSetting App.Title, "Config", frm.Name + "_width", CStr(frm.Width)
  10.     SaveSetting App.Title, "Config", frm.Name + "_height", CStr(frm.Height)
  11. End Sub
  12.  
  13.  
  14.  
  15. Public Sub LoadWindowPos(ByVal frm As Form)
  16.  
  17.     ' See if any settings are saved for this window
  18.  
  19.  
  20.     If GetSetting(App.Title, "Config", frm.Name + "_left", "") = "" Then
  21.         ' There aren't - so just centre the form on the screen
  22.         frm.Left = (Screen.Width - frm.Width) / 2
  23.         frm.Top = (Screen.Height - frm.Height) / 2
  24.         Exit Sub
  25.     End If
  26.  
  27.     ' Load the form's attributes from the registry
  28.     frm.Left = CLng(GetSetting(App.Title, "Config", frm.Name + "_left", "0"))
  29.     frm.Top = CLng(GetSetting(App.Title, "Config", frm.Name + "_top", "0"))
  30.     frm.Width = CLng(GetSetting(App.Title, "Config", frm.Name + "_width", CStr(frm.Width)))
  31.     frm.Height = CLng(GetSetting(App.Title, "Config", frm.Name + "_height", CStr(frm.Height)))
  32.     ' Optional - if the form is opening with any part off the screen
  33.     '     then nudge it back on
  34.     If frm.Left < 0 Then frm.Left = 0
  35.     If frm.Top < 0 Then frm.Top = 0
  36.     If frm.Left + frm.Width > Screen.Width Then frm.Left = Screen.Width - frm.Width
  37.     If frm.Top + frm.Height > Screen.Height Then frm.Top = Screen.Height - frm.Height
  38. End Sub
  39.  
  40.